<?php 
 // nusoap.php
	require_once('lib/nusoap.php');

    function getdata($username,$pwd){
		 include("connect/connect.php");
		mysql_select_db("dscc",$c);
		mysql_query("set names utf8");
		$sql="select prvid,ampid from user where email='$username' and pwd='$pwd'";
		$rs=mysql_query($sql);
		$result = mysql_fetch_array($rs);
		$prvid=$result["prvid"];
		$ampid=$result["ampid"];
		$plc_cond="";
		if($ampid<>""){
			$plc_cond=$ampid;
		}else{
			if($prvid<>""){
				$plc_cond=$prvid;
			}
		}
		if($plc_cond<>""){
        	$sql="select * from tempdsccformcc where rolplcid like '$plc_cond%' or  plcid like '$plc_cond%' or  evnplcid like '$plc_cond%'  limit 100";
			$rs=mysql_query($sql);
			//$result = mysql_fetch_array($rs);
			$str_return="";	//$str_return="code_acc,date_acc,time_acc,plcid_acc,type_acc1,type_acc2,type_acc3,cause,point_xy,point_x,point_y,trans,weapon1,weapon2,weapon3,weapon4,weapon5,weapon6,weapon7,weapon8,num_loss,num_dth,num_wnd,commt;";
			while ($result = mysql_fetch_array($rs)){
				$str_return=$str_return.$result["persiden"].",".$result["prenme"].",".$result["nme"].",".$result["surnme"].",".$result["age"].",".$result["roladr"].",".$result["rolvllno"].",".$result["rolplcnme"].",".$result["adr"].",".$result["vllno"].",".$result["plcplcnme"].",".$result["evndte"].",".$result["losbodynme"].",".$result["tel"].";";
			}
			return $str_return;
		}else{
			return "";
		}

	}

	function dataservice($username,$pwd){ 
		return getdata($username,$pwd);
	} 

 	$ws_server = new soap_server; // ҧ instance ͧ Soap-Server 
	//***WSDL File  
$ws_server->configureWSDL('dataserviceWSDL', 'http://localhost/dsccmis/webservice/');
 

$ws_server->register('dataservice',array('username'=>'xsd:string','pwd'=>'xsd:string'),array('data'=>'xsd:string'),'http://localhost/dsccmis/webservice/','http://localhost/dsccmis/webservice','rpc','encoded','send data');

// Use the request try to invoke the service 
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $ws_server->service($HTTP_RAW_POST_DATA); 
//echo getdata('','');

?> 
